package shopping;
import java.util.Scanner;
public class goods {
    private String name;
    private double price;
    private int count;
    private String []kinds;
    public goods(){}

    public goods(String name, double price, int count, String[] kinds) {
        this.name = name;
        this.price = price;
        this.count = count;
        this.kinds = kinds;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public String getKinds() {
        String join="";
        for (int i = 0; i < kinds.length; i++) {
            join+=kinds[i]+",";
        }
        return join;
    }

    public void setKinds(String[] kinds) {
        this.kinds = kinds;
    }

    public int downCount(goods goods) {//goods为goodAllInformation[i]
        int count=0;
        Scanner sc = new Scanner(System.in);
        while(true){
            count=sc.nextInt();
            if(goods.count<count){
                System.out.println("该商品数量超出库存，请重新输入数量！");
            } else{
                goods.count=goods.count-count;
                return count;
            }
        }
    }
    public String chooseKinds(goods goods) {//goods为goodAllInformation[i]
        Scanner sc = new Scanner(System.in);
        while(true){
            String kind=sc.nextLine();
            int flag=0;
            for (int i = 0; i < goods.kinds.length; i++) {
                if(goods.kinds[i].equals(kind)){
                    flag=1;
                }
            }
            if(flag==0){
                System.out.println("该商品没有此种种类，请重新输入种类！");
            }else{
                return kind;
            }
        }
    }
}
